package priv.lirenhe.exam.B;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class Example04 {
	
	public static void main(String[] args) {
		System.out.println(getUsedTimeA());
		System.out.println(getUsedTimeL());
	}
	
	public static String getUsedTimeA(){
		List<String> arrayList = new ArrayList<String>();
		
		long startTime = System.currentTimeMillis();
		for(int i=0; i<50000; i++){
			arrayList.add("0123456789");
		}
		long endTime = System.currentTimeMillis();
		
		long usedTimeL = endTime - startTime;
		float usedTimeF = 0.0F;
		if(usedTimeL > 1000){
			usedTimeF = usedTimeL / 1000;
			return usedTimeF + "秒";
		}
		
		return usedTimeL + "毫秒";
	}
	
	public static String getUsedTimeL(){
		List<String> linkedList = new LinkedList<String>();
		
		long startTime = System.currentTimeMillis();
		for(int i=0; i<50000; i++){
			linkedList.add("0123456789");
		}
		long endTime = System.currentTimeMillis();
		
		long usedTimeL = endTime - startTime;
		float usedTimeF = 0.0F;
		if(usedTimeL > 1000){
			usedTimeF = usedTimeL / 1000;
			return usedTimeF + "秒";
		}
		
		return usedTimeL + "毫秒";
	}

}

